{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d186b62d",
   "metadata": {},
   "source": [
    "# 主题：网页浏览行为关联规则挖掘 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "206eef8a",
   "metadata": {},
   "source": [
    "数据集链接：https://easylink.cc/iwp7os"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f3e9f8e2",
   "metadata": {},
   "source": [
    "## 实验目的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bf4736a3",
   "metadata": {},
   "source": [
    "### 1、利用挖掘工具快速实现数据的预处理分析，并实现关联算法的过程；"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccf551f8",
   "metadata": {},
   "source": [
    "### 2、了解Apriori、FP关联规则算法在实际中的应用；"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23153226",
   "metadata": {},
   "source": [
    "## 任务"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "272799d1",
   "metadata": {},
   "source": [
    "### 分析用户在网站上的浏览行为数据，挖掘潜在的跳转规律，为网站提供优化导航结构的建议。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "136eb35d",
   "metadata": {},
   "source": [
    "## 实验内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f95638b8",
   "metadata": {},
   "source": [
    "### 1、数据预处理。清洗数据，处理缺失值，提取用户浏览记录。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "b4e32236",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "data = pd.DataFrame(columns=['UserID', 'VrootID'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eaf7a013",
   "metadata": {},
   "source": [
    "### 先读取数据集文件并创建一个空的数据框，而后解析数据集文件并提取用户浏览记录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "addd9e89",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(r'C:\\Users\\30382\\Desktop\\data\\网页浏览数据集.data', 'r') as file:\n",
    "    lines = file.readlines()\n",
    "\n",
    "user_id = ''\n",
    "for line in lines:\n",
    "    line = line.strip()\n",
    "    line_type = line.split(',')[0]\n",
    "\n",
    "    if line_type == 'C':\n",
    "        user_id = line.split(',')[2]\n",
    "    elif line_type == 'V':\n",
    "        vroot_id = line.split(',')[1]\n",
    "        data = pd.concat([data, pd.DataFrame({'UserID': [user_id], 'VrootID': [vroot_id]})], ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a77b7945",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>UserID</th>\n",
       "      <th>VrootID</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10001</td>\n",
       "      <td>1000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10001</td>\n",
       "      <td>1001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10001</td>\n",
       "      <td>1002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10002</td>\n",
       "      <td>1001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10002</td>\n",
       "      <td>1003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98649</th>\n",
       "      <td>42709</td>\n",
       "      <td>1003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98650</th>\n",
       "      <td>42710</td>\n",
       "      <td>1035</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98651</th>\n",
       "      <td>42710</td>\n",
       "      <td>1001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98652</th>\n",
       "      <td>42710</td>\n",
       "      <td>1018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98653</th>\n",
       "      <td>42711</td>\n",
       "      <td>1008</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>98654 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      UserID VrootID\n",
       "0      10001    1000\n",
       "1      10001    1001\n",
       "2      10001    1002\n",
       "3      10002    1001\n",
       "4      10002    1003\n",
       "...      ...     ...\n",
       "98649  42709    1003\n",
       "98650  42710    1035\n",
       "98651  42710    1001\n",
       "98652  42710    1018\n",
       "98653  42711    1008\n",
       "\n",
       "[98654 rows x 2 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = data.dropna()  # 删除包含缺失值的行\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2faddac",
   "metadata": {},
   "source": [
    "### 2.数据探索性分析。分析最常被访问的页面、页面访问量分布等。\n",
    "### 首先，可以计算每个页面的访问量，并找出最常被访问的页面："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9cd062d5",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "最常被访问的页面：\n",
      "VrootID\n",
      "1008    10836\n",
      "1034     9383\n",
      "1004     8463\n",
      "1018     5330\n",
      "1017     5108\n",
      "1009     4628\n",
      "1001     4451\n",
      "1026     3220\n",
      "1003     2968\n",
      "1025     2123\n",
      "1035     1791\n",
      "1040     1506\n",
      "1041     1500\n",
      "1032     1446\n",
      "1037     1160\n",
      "1030     1115\n",
      "1038     1110\n",
      "1020     1087\n",
      "1000      912\n",
      "1007      865\n",
      "1052      842\n",
      "1036      759\n",
      "1002      749\n",
      "1014      728\n",
      "1295      716\n",
      "1010      698\n",
      "1058      672\n",
      "1053      670\n",
      "1046      636\n",
      "1070      602\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# 计算每个页面的访问量\n",
    "page_visits = data['VrootID'].value_counts()\n",
    "\n",
    "# 找出最常被访问的页面\n",
    "most_visited_pages = page_visits.head(30)\n",
    "\n",
    "# 打印最常被访问的页面\n",
    "print(\"最常被访问的页面：\")\n",
    "print(most_visited_pages)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa4ad0a4",
   "metadata": {},
   "source": [
    "### 接下来，可以绘制页面访问量的分布图："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "427744a3",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA90AAAJOCAYAAACqS2TfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAABPqklEQVR4nO3deXQUVcL+8aeTkAQIhISwBZDNCARZRIKRERFkQFmCyow/EBURzojIsKgoOLKNCIgKygyubIoI4zCizouAg6xiZBuI8AZQIWxBIGxZCAkJub8/OPRLkwAx9E2F9PdzTp9D1+3q51aT7s6T6upyGWOMAAAAAACA1/k5PQEAAAAAAEorSjcAAAAAAJZQugEAAAAAsITSDQAAAACAJZRuAAAAAAAsoXQDAAAAAGAJpRsAAAAAAEso3QAAAAAAWELpBgDAR2RlZeno0aNOTwMAAJ9C6QYAwEsyMzOVnZ0tY0yh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4eWhoaL7lFz++febMGf38888KDAzUjBkztG7dunzHe+fm5iorK8u9p3vixIn67LPPtG3bNnXq1KlQ23vpXv2LsrOzlZ6erjfeeOOK6509e/aqHxFfv369pk+frr///e+qVKmSx9jw4cP11VdfqXv37lq5cqWio6PdY3feeafOnDnj3jN//PhxNWrUSEOHDtXo0aP13nvv6ZZbblGHDh0KtX0AAFwPSjcAAF7Ws2dPLV++PN/ysLAwj+vDhg3z2Ou8d+/eAo83TkhI8NjTe1FwcLDOnj3rvv7ggw8qOztbfn5+evLJJ/XQQw/p5ptvlnThOO3AwMBr7m3PysrSyZMnJV3YQ3/xePHL1ahRI9/H3aULXybn7++vRx55RI888shVsy66+BH3smXLuj9af+rUKfXt21cdOnTQwIED863j7++vxYsX695779Xvfvc7zZkzRw888IB7rFy5cu7bPv/886patapefPFFSRf2Znfr1o3SDQAoFpRuAAC8LDg4WD169NAXX3xxxds0atRIwcHBHssultiff/5ZN998s3r16qXY2FgNGzZMkvTEE0+oUaNGGjlypBYtWqT+/ft7rH/u3DmdPHlSW7duVceOHT3GjDE6e/asfvnll3xzrVWrlvt6YGCgu/ju3btXjRo1KnD+8fHxio2Nzbd8yJAhmj9/voKDgxUaGqqAgKv/qpGbm6tTp04pKytLP/30k+rUqaMzZ87ogQceUFZWloYPH67ExMR8x5Jf9P7772vEiBF68MEH9fDDD2vevHkeH3f/8MMP9cknn+irr77SsWPHJF34REFmZqYOHTrkcV+XPg4AAHgLpRsAAC8LCAjw+Nj0nDlztG7dOr333nsehfDyIlmmTJl89zV8+HANHz7cfX3SpElXvP2SJUskXSiPlx9nnZ6ero0bN+bbk96pU6cC98pL//dHgKSkJNWtW1eStG/fPtWrV++Kx3HPnDlTM2fO1IYNGxQfH1/gbS7Xr18/j4/Jv/baa9q2bZtWrVql1q1b6/z581dd/9ChQ/rb3/6mihUreszrq6++0jPPPKPz58+ra9euHuts3rxZkydPdl93uVzKy8sr1HwBAPgtOGUYAACWJSQkaNWqVVcsqlczbdo0GWNk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whNINAAAAAIAllG4AAAAAACyhdAMAAAAAYAmlGwAAAAAASyjdAAAAAABYQukGAAAAAMASSjcAAAAAAJZQugEAAAAAsITSDQAAAACAJZRuAAAAAAAsoXQDAAAAAGAJpRsAAAAAAEso3QAAAAAAWELpBgAAAADAEko3AAAAAACWULoBAAAAALCE0g0AAAAAgCWUbgAAAAAALAlwegK48dQduaTI6+6b3NWLMwEAAACAko093QAAAAAAWELpBgAAAADAEko3AAAAAACWULoBAAAAALCE0g0AAAAAgCWUbgAAAAAALKF0AwAAAABgCaUbAAAAAABLKN0AAAAAAFhC6QYAAAAAwBJKNwAAAAAAllC6AQAAAACwhNINAAAAAIAllG4AAAAAACwpkaV75syZql27tsqVK6d77rlHe/fulSTt2LFDMTExCgsL04gRI2SMca+zZs0aNW7cWBEREZo6darH/S1atEh16tRRZGSkFixYUKzbAgAAAADwXSWudO/Zs0d//etf9eWXX2rXrl1q0KCBnnjiCWVnZ6t79+66/fbbtXnzZiUmJmru3LmSpJSUFMXFxal3796Kj4/X/PnztWrVKkkXinqfPn00evRoLV++XGPGjNHu3bsd3EIAAAAAgK8ocaV769atio2NVcuWLXXTTTfpySef1C+//KKlS5cqNTVVU6dOVYMGDTRx4kTNmjVLkjR//nxFRkZq9OjRioqK0pgxY9xjM2fOVPv27TVgwAA1bdpUgwcP1rx585zcRAAAAACAjyhxpTs6OlorV67Utm3blJqaqnfeeUe///3vlZCQoNjYWJUrV06S1KxZMyUmJkqSEhIS1L59e7lcLklS69attWXLFvdYhw4d3Pd/6RgAAAAAADYFOD2By0VHR+sPf/iDbrvtNklSvXr1tGHDBk2ePFn16tVz387lcsnf31+nTp1SWlqaoqOj3WMVK1bU4cOHJUlpaWke6106VpDs7GxlZ2e7r6elpXlt2wAAAAAAvqXE7eneuHGj/v3vf+uHH37Q6dOn1bt3b3Xp0kUBAQEKCgryuG1wcLAyMzPzjV1cLumqYwWZNGmSQkND3ZfatWt7eQsBAAAAAL6ixJXuBQsWqFevXrrjjjsUGh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Gui+1a9cu8rYAAAAAAHxbwPWsbIzR22+/raNHj+rYsWNKT09X3759deTIkSLf5+eff64zZ85o1apVioiIUG5urpo2barZs2erX79+HrcNDg5WZmamAgICFBQUlG+5pKuOFWTUqFF69tln3dfT0tIo3gAAAACAIrmuPd0ul0tvvPGGmjRpoieffFK33nqrNm3apEaNGhX5Pg8dOqTY2FhFRERIulCamzVrptOnTyslJcXjtunp6QoMDFR4eLjH2MXlkq46VpCgoCBVrFjR4wIAAAAAQFFc98fLpQvl21vHddeqVUtnz571WLZ//3699dZbio+Pdy9LSkpSdna2wsPDFRMT4zG2detW1axZU5KuOgYAAAAAgE2FLt1HjhzRsWPHtGTJEo/l8fHxOnnypE6ePClJHufOLoquXbsqMTFR7733ng4dOqTp06crISFBDz30kNLS0jRnzhxJ0sSJE9WxY0f5+/srLi5O69ev14oVK5STk6MpU6aoc+fOkqSePXtq4cKF2r59uzIyMjR9+nT3GAAAAAAANhX6mO7Y2FgFBQXp8OHD6tq1q9asWaNatWrp66+/Vv369VWhQgWdO3dOx44du67iXblyZX399dd6/vnn9eyzz6pGjRr67LPPVLt2bc2cOVO9e/fWiBEj5Ofnp9WrV0uSIiIiNG3aNHXp0kUhISGqVKmS+xzezZs319ChQ9WqVSsFBwcrKipKgwYNKvL8AAAAAAAoLJcpYkNu2bKl/vvf/3osO3TokKpXr6477rjjqqfluh5HjhzRli1bFBsbq8qVK3uMJSUladeuXWrbtq1CQkI8xhITE5WcnKx27dpd9Zjuy6WlpSk0NFSpqakFHt9dd+SSAtYqnH2TuxZ53evJdTL7enIBAAAAoKS4Vle8qMjfXv7//t//y7esVq1akuT+CLgN1atXV9euBRe3evXqeZwe7FLR0dGKjo62Ni8AAAAAAC5X5C9Se/HFF6841qxZs6LeLQAAAAAApUah93TPmDFDgYGB8vf3v+rtgoKC1KFDB9WoUeO6JwcAAAAAwI2s0KV72LBhuuuuu655u9OnT+uDDz7QmjVrrmtiAAAAAADc6ApdukNCQrRq1apr3u748eO6+eabr2t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ASSjcAAAAAAJZQugEAAAAAsITSDQAAAACAJZRuAAAAAAAsoXQDAAAAAGAJpRsAAAAAAEso3QAAAAAAWELpBgAAAADAkgCnJwAATqs7ckmR1903uasXZwIAAIDShj3dAAAAAABYQukGAAAAAMASSjcAAAAAAJZQugEAAAAAsITSDQAAAACAJZRuAAAAAAAsoXQDAAAAAGAJpRsAAAAAAEso3QAAAAAAWELpBgAAAADAEko3AAAAAACWULoBAAAAALCE0g0AAAAAgCWUbgAAAAAALKF0AwAAAABgCaUbAAAAAABLKN0AAAAAAFhC6QYAAAAAwBJKNwAAAAAAllC6AQAAAACwhNINAAAAAIAllG4AAAAAACyhdAMAAAAAYAmlGwAAAAAASyjdAAAAAABYQukGAAAAAMASSjcAAAAAAJZQugEAAAAAsITSDQAAAACAJZRuAAAAAAAsoXQDAAAAAGAJpRsAAAAAAEso3QAAAAAAWELpBgAAAADAEko3AAAAAACWULoBAAAAALAkwOkJAICvqjtyyXWtv29yVy/NBAAAALaUyD3dX375perXr6+AgAC1aNFCO3fulCTt2LFDMTExCgsL04gRI2SMca+zZs0aNW7cWBEREZo6darH/S1atEh16tRRZGSkFixYUKzbAgAAAADwXSWudO/Zs0f9+vXT5MmTlZycrFtuuUUDBgxQdna2unfvrttvv12bN29WYmKi5s6dK0lKSUlRXFycevfurfj4eM2fP1+rVq2SdKGo9+nTR6NHj9by5cs1ZswY7d6928EtBAAAAAD4ihJXunfu3KnJkyfr4YcfVrVq1fT0009r69atWrp0qVJTUzV16lQ1aNBAEydO1KxZsyRJ8+fPV2RkpEaPHq2oqCiNGTPGPTZz5ky1b99eAwYMUNOmTTV48GDNmzfPyU0EAAAAAPiIEle6u3Xrpj/96U/u67t371ZUVJQSEhIUGxurcuXKSZKaNWumxMRESVJCQoLat28vl8slSWrdurW2bNniHuvQoYP7/i4dK0h2drbS0tI8LgAAAAAAFEWJK92XOnfunN58800NHDhQaWlpqlevnnvM5XLJ399fp06dyjdWsWJFHT58WJKuOlaQSZMmKTQ01H2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8xo6KiTEZGhjHGmAMHDpj77rvP+Pv7G5fLZQICAkz//v3d7102+NJr13fffWfat29vmjVrZsaNG2dyc3PN888/b8LDw02VKlXMM888Y86ePev13MsNHjzY+Pn5mWrVqpkyZcqYZs2amZ9++slaXnG/ZlK6vahfv34mJibGvPrqq6Zp06amR48epkuXLiYhIcEsW7bMNGjQwDz00ENez23atKnx8/Mz9evXN+3btzf33HOP+xIQEGBiY2NN+/btvZ5bo0YN4+fnZ6pUqWLq1atn6tat6774+fmZWrVqWXkD6NGjh+natauZP3++6dChg7njjjtMv379TGpqqtm1a5e57bbbTIcOHbyea8yFXzASEhLMn/70J1O1alUzdOjQfG98NowZM8Y0aNDAvPPOO+b99983d911lwkMDDQDBw40R44csZ5f3IYMGWLS0tKMMcb85z//MS1btjTp6enGmAu/5LzwwgumWbNmXs89d+6cqVWrlunXr5+ZPn26adGihbn//vvNTTfdZObMmWM++eQT06JFC/OXv/zF69l+fn4mNTXVGGNMr169zB133GHWrl1rdu3aZWbPnm2qV69uJkyYUGpyFyxYYKKiosz06dNNfHy8+d///V+zZ88es23bNjNnzhxz2223mdatW5ucnByvZzvlnnvuMXfffbeZM2eOGTlypAkLCzPdu3c3KSkpxpgLv1S7XC6v5zr1ujVt2jRz++23my+//NL8+uuv5syZM+b8+fPm9OnTZuXKleb+++83DRo08PofApx8j3Bqm516PrlcLrN06VLTqVMnc8stt5hp06aZ06dPezWjIE49l4xx7v3pwQcfNI0aNTJjx441vXr1MkFBQebPf/6zuwzZ2manfsd0uVzu96b77rvPdOvWzRw4cMBkZWWZlStXmoYNG5rhw4d7PdcY33rtOnPmjAkPDzfjxo0zX331lencubNp1qyZadasmVm1apX57rvvTKdOncxTTz3l1VxjjJk6darJzc01xhjz/fffm6ioKHPw4EFjjDHp6enmscceM23atPF6rjHOvGZSur0oLCzM7NixwxhjzL59+4yfn585dOiQe/z999835cqV83puTk6OmTBhggkLCzNTpkwxeXl57rFKlSpZ2dtsjDGnTp0yAwYMMNWqVTOf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vbfccovWrl2rP/7xj7rjjju0ePFir2dKzv2OaYzR999/r8zMTNWsWdPjOXxxXrm5uVayfem1q06dOkpOTtaRI0ckSeXLl9fChQv1u9/9zn2bhIQEd7/xpu+++05PP/20HnjgAU2dOlVbtmzxGN+zZ49q1arl9VzJoddMr9V3mIEDB5p7773XvPvuu6ZNmzamWbNmpl27duZ//ud/zOzZs01UVJTp27ev9Xlc/Ejoyy+/bEJDQ639FfJS2dnZZsyYMaZ69epm5syZJiwszFruX//6V9O0aVPz4osvmltuucXcd999pkmTJubvf/+7GTNmjKlWrZoZNmyYlexL9wpeyaV/ifaW559/3jRt2tQsXrzYbN682bz88svmpptu8viLs41jqoy5sPe3Tp065vDhw1bu/2rOnDljRowYYYKCgkydOnVM//79zSOPPGJCQkLMv//9byuZw4cPNw0bNvT4K+9Fn376qalataqZNm2a13O7d+9uIiMjTWRkpKlatarp1KmTe+y7774zMTExpn///qUm95///KcJCgoy999/v3n99dfNokWLzL///W8ze/ZsM2DAAFOhQgXz8ssvez3XGOd+pt9//31TvXp18+WXX+Yb27Rpk/uQHW9z6nVr9erVJjQ01ERHR5tnnnnGvPHGG+Zvf/ubGTNmjOnYsaMpV66cef/9972e6+R7hFPb7NTz6Vo/W2fPnjXffvut13Odei5dqrjfn8aNG2caNmxofvjhh3xjX331lQkJCSmW49iL63fMP//5z6ZNmzYmNDTUVKhQwcTExLjHPv30U1O/fn3z0ksvWcn2tdeuadOmmRo1ahT4c/vmm2+aChUqmAULFng996Lk5GTzxz/+0bhcLnPnnXeaV155xbz00kumSpUqZvbs2VYynXjNdBnD105607x587Rx40Y1adJEAwYM0FtvvaVPP/1UeXl5atu2rSZMmGDlr0WXS0lJ0bBhw7RgwQLt27dPN910k/VMSdq5c6f+9Kc/af369VZz161b536c77vvPi1atMjjcf7zn/+swMBAr+eOHz9eo0aNsnLfV5Obm6tx48Zp3rx5On78uFq2bKkZM2aoWbNmxZKfmZmpMmXKqEyZMsWSd7kDBw7oo48+0qFDh1SrVi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ACwhNINAAAAAIAllG4AAAAAACyhdAMAAAAAYMn/B8Ff2Fjjfs4wAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 1000x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.rcParams['font.sans-serif'] = ['SimHei']  # 使用中文字体（示例为SimHei）\n",
    "\n",
    "# 绘制页面访问量的分布图\n",
    "plt.figure(figsize=(10, 6))\n",
    "most_visited_pages.plot(kind='bar')\n",
    "plt.xlabel(\"页面ID\")\n",
    "plt.ylabel(\"访问量\")\n",
    "plt.title(\"页面访问量分布\")\n",
    "plt.tight_layout()  # 自动调整图像布局\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "044f8514",
   "metadata": {},
   "source": [
    "我截取了最常访问的30个页面，数据差异较大，最常被访问的1008页面\"Free Downloads\"访问量达到了10836，而排在第30名的1070页面\"ActiveX Technology Development\"访问量则只有865，更不用说排名更低的页面了。对于页面访问量分布，我们可以看到大多数页面的访问量相对较低，只有少数几个页面的访问量较高。这符合“长尾分布”（Long Tail Distribution）的特点，即少数页面拥有大量的访问量，而大多数页面的访问量较低。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a7d2543",
   "metadata": {},
   "source": [
    "### 3、关联规则挖掘。\n",
    "### 使用Apriori算法或FP-growth算法，根据用户浏览记录计算频繁项集和关联规则。关联规则挖掘是一种常用的数据挖掘技术，可以从数据集中发现项集之间的关联关系。 在这个实验中，我将使用Apriori算法来计算频繁项集和关联规则。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1e06aaa9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入mlxtend库，包含了许多经典的机器学习算法，如预处理、分类、回归、聚类、维度缩减和模型选择\n",
    "#还有包括频繁模式和关联规则挖掘在内的数据挖掘算法\n",
    "from mlxtend.preprocessing import TransactionEncoder\n",
    "from mlxtend.frequent_patterns import apriori, association_rules"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "23f5a474",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>1000</th>\n",
       "      <th>1001</th>\n",
       "      <th>1002</th>\n",
       "      <th>1003</th>\n",
       "      <th>1004</th>\n",
       "      <th>1005</th>\n",
       "      <th>1006</th>\n",
       "      <th>1007</th>\n",
       "      <th>1008</th>\n",
       "      <th>1009</th>\n",
       "      <th>...</th>\n",
       "      <th>1276</th>\n",
       "      <th>1277</th>\n",
       "      <th>1278</th>\n",
       "      <th>1279</th>\n",
       "      <th>1280</th>\n",
       "      <th>1281</th>\n",
       "      <th>1282</th>\n",
       "      <th>1283</th>\n",
       "      <th>1284</th>\n",
       "      <th>1295</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32706</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32707</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32708</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32709</th>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32710</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>32711 rows × 285 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        1000   1001   1002   1003   1004   1005   1006   1007   1008   1009  \\\n",
       "0       True   True   True  False  False  False  False  False  False  False   \n",
       "1      False   True  False   True  False  False  False  False  False  False   \n",
       "2      False   True  False   True   True  False  False  False  False  False   \n",
       "3      False  False  False  False  False   True  False  False  False  False   \n",
       "4      False  False  False  False  False  False   True  False  False  False   \n",
       "...      ...    ...    ...    ...    ...    ...    ...    ...    ...    ...   \n",
       "32706  False  False  False  False   True  False  False  False   True   True   \n",
       "32707  False  False  False  False  False  False  False  False   True  False   \n",
       "32708  False   True  False   True  False  False  False  False  False  False   \n",
       "32709  False   True  False  False  False  False  False  False  False  False   \n",
       "32710  False  False  False  False  False  False  False  False   True  False   \n",
       "\n",
       "       ...   1276   1277   1278   1279   1280   1281   1282   1283   1284  \\\n",
       "0      ...  False  False  False  False  False  False  False  False  False   \n",
       "1      ...  False  False  False  False  False  False  False  False  False   \n",
       "2      ...  False  False  False  False  False  False  False  False  False   \n",
       "3      ...  False  False  False  False  False  False  False  False  False   \n",
       "4      ...  False  False  False  False  False  False  False  False  False   \n",
       "...    ...    ...    ...    ...    ...    ...    ...    ...    ...    ...   \n",
       "32706  ...  False  False  False  False  False  False  False  False  False   \n",
       "32707  ...  False  False  False  False  False  False  False  False  False   \n",
       "32708  ...  False  False  False  False  False  False  False  False  False   \n",
       "32709  ...  False  False  False  False  False  False  False  False  False   \n",
       "32710  ...  False  False  False  False  False  False  False  False  False   \n",
       "\n",
       "        1295  \n",
       "0      False  \n",
       "1      False  \n",
       "2      False  \n",
       "3      False  \n",
       "4      False  \n",
       "...      ...  \n",
       "32706  False  \n",
       "32707  False  \n",
       "32708  False  \n",
       "32709  False  \n",
       "32710  False  \n",
       "\n",
       "[32711 rows x 285 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将数据集转换成适合Apriori算法处理的形式\n",
    "user_data = []\n",
    "last_user = '10001'\n",
    "tmp = []\n",
    "\n",
    "for index, row in data.iterrows():\n",
    "    user_id = row['UserID']\n",
    "    vroot_id = row['VrootID']\n",
    "        \n",
    "    if user_id == last_user:\n",
    "        tmp.append(vroot_id)\n",
    "    else:\n",
    "        user_data.append(tmp)\n",
    "        tmp = []\n",
    "        tmp.append(vroot_id)\n",
    "    last_user = user_id\n",
    "\n",
    "user_data.append(tmp)\n",
    "# user_data\n",
    "\n",
    "te = TransactionEncoder()\n",
    "data_encoded = te.fit_transform(user_data)\n",
    "df = pd.DataFrame(data_encoded, columns=te.columns_)\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "72fefa0e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Frequent Itemsets:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>support</th>\n",
       "      <th>itemsets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.136070</td>\n",
       "      <td>(1001)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.090734</td>\n",
       "      <td>(1003)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.258720</td>\n",
       "      <td>(1004)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.331265</td>\n",
       "      <td>(1008)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.141481</td>\n",
       "      <td>(1009)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.156155</td>\n",
       "      <td>(1017)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.162942</td>\n",
       "      <td>(1018)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.064902</td>\n",
       "      <td>(1025)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.098438</td>\n",
       "      <td>(1026)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.286845</td>\n",
       "      <td>(1034)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.054752</td>\n",
       "      <td>(1035)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.055211</td>\n",
       "      <td>(1003, 1001)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.059430</td>\n",
       "      <td>(1018, 1001)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0.060438</td>\n",
       "      <td>(1008, 1004)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.053285</td>\n",
       "      <td>(1034, 1004)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0.077925</td>\n",
       "      <td>(1009, 1008)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.061233</td>\n",
       "      <td>(1008, 1017)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.073064</td>\n",
       "      <td>(1008, 1018)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.160802</td>\n",
       "      <td>(1034, 1008)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     support      itemsets\n",
       "0   0.136070        (1001)\n",
       "1   0.090734        (1003)\n",
       "2   0.258720        (1004)\n",
       "3   0.331265        (1008)\n",
       "4   0.141481        (1009)\n",
       "5   0.156155        (1017)\n",
       "6   0.162942        (1018)\n",
       "7   0.064902        (1025)\n",
       "8   0.098438        (1026)\n",
       "9   0.286845        (1034)\n",
       "10  0.054752        (1035)\n",
       "11  0.055211  (1003, 1001)\n",
       "12  0.059430  (1018, 1001)\n",
       "13  0.060438  (1008, 1004)\n",
       "14  0.053285  (1034, 1004)\n",
       "15  0.077925  (1009, 1008)\n",
       "16  0.061233  (1008, 1017)\n",
       "17  0.073064  (1008, 1018)\n",
       "18  0.160802  (1034, 1008)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c# 使用Apriori算法计算频繁项集\n",
    "frequent_itemsets = apriori(df, min_support=0.05, use_colnames=True)\n",
    "\n",
    "# 打印频繁项集\n",
    "print(\"Frequent Itemsets:\")\n",
    "# print(frequent_itemsets)\n",
    "frequent_itemsets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "606de39c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Association Rules:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>antecedents</th>\n",
       "      <th>consequents</th>\n",
       "      <th>antecedent support</th>\n",
       "      <th>consequent support</th>\n",
       "      <th>support</th>\n",
       "      <th>confidence</th>\n",
       "      <th>lift</th>\n",
       "      <th>leverage</th>\n",
       "      <th>conviction</th>\n",
       "      <th>zhangs_metric</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>(1003)</td>\n",
       "      <td>(1001)</td>\n",
       "      <td>0.090734</td>\n",
       "      <td>0.136070</td>\n",
       "      <td>0.055211</td>\n",
       "      <td>0.608491</td>\n",
       "      <td>4.471879</td>\n",
       "      <td>0.042865</td>\n",
       "      <td>2.206663</td>\n",
       "      <td>0.853854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>(1001)</td>\n",
       "      <td>(1003)</td>\n",
       "      <td>0.136070</td>\n",
       "      <td>0.090734</td>\n",
       "      <td>0.055211</td>\n",
       "      <td>0.405752</td>\n",
       "      <td>4.471879</td>\n",
       "      <td>0.042865</td>\n",
       "      <td>1.530111</td>\n",
       "      <td>0.898662</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>(1018)</td>\n",
       "      <td>(1001)</td>\n",
       "      <td>0.162942</td>\n",
       "      <td>0.136070</td>\n",
       "      <td>0.059430</td>\n",
       "      <td>0.364728</td>\n",
       "      <td>2.680435</td>\n",
       "      <td>0.037258</td>\n",
       "      <td>1.359936</td>\n",
       "      <td>0.748964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>(1001)</td>\n",
       "      <td>(1018)</td>\n",
       "      <td>0.136070</td>\n",
       "      <td>0.162942</td>\n",
       "      <td>0.059430</td>\n",
       "      <td>0.436756</td>\n",
       "      <td>2.680435</td>\n",
       "      <td>0.037258</td>\n",
       "      <td>1.486137</td>\n",
       "      <td>0.725668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>(1009)</td>\n",
       "      <td>(1008)</td>\n",
       "      <td>0.141481</td>\n",
       "      <td>0.331265</td>\n",
       "      <td>0.077925</td>\n",
       "      <td>0.550778</td>\n",
       "      <td>1.662652</td>\n",
       "      <td>0.031057</td>\n",
       "      <td>1.488652</td>\n",
       "      <td>0.464231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>(1017)</td>\n",
       "      <td>(1008)</td>\n",
       "      <td>0.156155</td>\n",
       "      <td>0.331265</td>\n",
       "      <td>0.061233</td>\n",
       "      <td>0.392130</td>\n",
       "      <td>1.183736</td>\n",
       "      <td>0.009504</td>\n",
       "      <td>1.100129</td>\n",
       "      <td>0.183940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>(1018)</td>\n",
       "      <td>(1008)</td>\n",
       "      <td>0.162942</td>\n",
       "      <td>0.331265</td>\n",
       "      <td>0.073064</td>\n",
       "      <td>0.448405</td>\n",
       "      <td>1.353616</td>\n",
       "      <td>0.019087</td>\n",
       "      <td>1.212367</td>\n",
       "      <td>0.312091</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>(1034)</td>\n",
       "      <td>(1008)</td>\n",
       "      <td>0.286845</td>\n",
       "      <td>0.331265</td>\n",
       "      <td>0.160802</td>\n",
       "      <td>0.560588</td>\n",
       "      <td>1.692267</td>\n",
       "      <td>0.065780</td>\n",
       "      <td>1.521888</td>\n",
       "      <td>0.573616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>(1008)</td>\n",
       "      <td>(1034)</td>\n",
       "      <td>0.331265</td>\n",
       "      <td>0.286845</td>\n",
       "      <td>0.160802</td>\n",
       "      <td>0.485419</td>\n",
       "      <td>1.692267</td>\n",
       "      <td>0.065780</td>\n",
       "      <td>1.385894</td>\n",
       "      <td>0.611717</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  antecedents consequents  antecedent support  consequent support   support  \\\n",
       "0      (1003)      (1001)            0.090734            0.136070  0.055211   \n",
       "1      (1001)      (1003)            0.136070            0.090734  0.055211   \n",
       "2      (1018)      (1001)            0.162942            0.136070  0.059430   \n",
       "3      (1001)      (1018)            0.136070            0.162942  0.059430   \n",
       "4      (1009)      (1008)            0.141481            0.331265  0.077925   \n",
       "5      (1017)      (1008)            0.156155            0.331265  0.061233   \n",
       "6      (1018)      (1008)            0.162942            0.331265  0.073064   \n",
       "7      (1034)      (1008)            0.286845            0.331265  0.160802   \n",
       "8      (1008)      (1034)            0.331265            0.286845  0.160802   \n",
       "\n",
       "   confidence      lift  leverage  conviction  zhangs_metric  \n",
       "0    0.608491  4.471879  0.042865    2.206663       0.853854  \n",
       "1    0.405752  4.471879  0.042865    1.530111       0.898662  \n",
       "2    0.364728  2.680435  0.037258    1.359936       0.748964  \n",
       "3    0.436756  2.680435  0.037258    1.486137       0.725668  \n",
       "4    0.550778  1.662652  0.031057    1.488652       0.464231  \n",
       "5    0.392130  1.183736  0.009504    1.100129       0.183940  \n",
       "6    0.448405  1.353616  0.019087    1.212367       0.312091  \n",
       "7    0.560588  1.692267  0.065780    1.521888       0.573616  \n",
       "8    0.485419  1.692267  0.065780    1.385894       0.611717  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据频繁项集计算关联规则\n",
    "rules = association_rules(frequent_itemsets, metric=\"confidence\", min_threshold=0.3)\n",
    "\n",
    "# 打印关联规则\n",
    "print(\"\\nAssociation Rules:\")\n",
    "# print(rules)\n",
    "rules"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b003167d",
   "metadata": {},
   "source": [
    "### 接下来对关联规则进行评价，使用Lift和卡方两个指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "445dbc8e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "关联规则提升度:\n",
      "  antecedents consequents  lift\n",
      "0      (1003)      (1001)  4.47\n",
      "1      (1001)      (1003)  4.47\n",
      "2      (1018)      (1001)  2.68\n",
      "3      (1001)      (1018)  2.68\n",
      "4      (1009)      (1008)  1.66\n",
      "5      (1017)      (1008)  1.18\n",
      "6      (1018)      (1008)  1.35\n",
      "7      (1034)      (1008)  1.69\n",
      "8      (1008)      (1034)  1.69\n",
      "\n",
      "卡方检验结果:\n",
      "卡方值: 17762.4449056227\n"
     ]
    }
   ],
   "source": [
    "# 计算提升度\n",
    "rules['lift'] = rules['lift'].apply(lambda x: round(x, 2))\n",
    "\n",
    "# 进行卡方检验\n",
    "observed = rules['support'] * len(df)  # 观察到的频数\n",
    "expected = rules['antecedent support'] * rules['consequent support'] * len(df)  # 期望频数\n",
    "chi_squared = ((observed - expected) ** 2 / expected).sum()  # 计算卡方值\n",
    "\n",
    "# 输出结果\n",
    "print(\"关联规则提升度:\")\n",
    "print(rules[['antecedents', 'consequents', 'lift']])\n",
    "print(\"\\n卡方检验结果:\")\n",
    "print(\"卡方值:\", chi_squared)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4db64627",
   "metadata": {},
   "source": [
    "### 4、结果评估"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db5d0206",
   "metadata": {},
   "source": [
    "结果评估任务：计算关联规则的支持度、置信度和提升度，得出强关联规则。 关联规则的支持度、置信度和提升度分别如上述结果\n",
    "\n",
    "中\"support\"、\"confidence\"和\"lift\"列所表示。将置信度阈值设为0.5，提升度阈值设为1，可得出强关联规则有：\n",
    "\n",
    "关联规则: (1003) -> (1001)\n",
    "\n",
    "置信度：0.608491\n",
    "\n",
    "提升度：4.471879\n",
    "\n",
    "关联规则: (1009) -> (1008)\n",
    "\n",
    "置信度：0.550778\n",
    "\n",
    "提升度：1.662652\n",
    "\n",
    "关联规则: (1034) -> (1008)\n",
    "\n",
    "置信度：0.560588\n",
    "\n",
    "提升度：1.692267\n",
    "\n",
    "这些关联规则具有较高的置信度和提升度，可以被认为是强关联规则。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72be0c10",
   "metadata": {},
   "source": [
    "### 5、总结"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e9c0c4d4",
   "metadata": {},
   "source": [
    "分析得到的关联规则，为网站提供导航结构优化建议，以提升用户体验。 根据得到的强关联规则可知，在网站导航中，将页面1001（\"Support Desktop\"）作为页面1003（\"Knowledge Base\"）的相关链接或者子页面，以便用户在访问页面(1003)时能够轻松地浏览和导航到页面(1001)；同理，也可以将页面1008（\"Free Downloads\"）作为页面1009（\"Windows Family of OSs\"）和页面1034（\"Internet Explorer\"）的相关链接或者子页面，以便于用户跳转链接，方便用户上网。这些建议旨在根据关联规则优化网站的导航结构，以提升用户体验，通过将相关页面链接在一起，用户可以更方便地浏览和访问相关内容，减少了用户在网站中的迷失感，提高了用户的满意度和导航效率。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
